using System;
using UnityEngine;

public class Waypoint : MonoBehaviour
{
	[SerializeField]
	private WaypointEvent[] _events;

	public Action<Waypoint> OnArrivalCallback;

	private bool _arrived;

	public WaypointEvent[] Events => _events;

	public bool Arrived
	{
		get
		{
			return _arrived;
		}
		set
		{
			_arrived = value;
			OnArrivalCallback.Fire(this);
		}
	}

	public bool ShouldStop
	{
		get
		{
			WaypointEvent[] events = _events;
			foreach (WaypointEvent waypointEvent in events)
			{
				if (waypointEvent.Type == WaypointEvent.EventType.Stop)
				{
					return true;
				}
			}
			return false;
		}
	}

	public int Index
	{
		get;
		set;
	}

	public void SetPosition(float x, float y, float z)
	{
		base.gameObject.transform.position = new Vector3(x, y, z);
	}

	public void SetPosition(Vector3 newPosition)
	{
		base.gameObject.transform.position = newPosition;
	}

	public void SetLocalPosition(float x, float y, float z)
	{
		base.gameObject.transform.localPosition = new Vector3(x, y, z);
	}

	public void SetLocalPosition(Vector3 newPosition)
	{
		base.gameObject.transform.localPosition = newPosition;
	}

	public Vector3 GetPosition()
	{
		return base.gameObject.transform.position;
	}
}
